            
class PositioneController {
    
    def index = { redirect(action:list,params:params) }

    // the delete, save and update actions only accept POST requests
    def allowedMethods = [delete:'POST', save:'POST', update:'POST']

    def list = {
        if(!params.max) params.max = 10
        [ positioneList: Positione.list( params ) ]
    }

    def show = {
        def positione = Positione.get( params.id )

        if(!positione) {
            flash.message = "Position not found with id ${params.id}"
            redirect(action:list)
        }
        else { return [ positione : positione ] }
    }

    def delete = {
        def positione = Positione.get( params.id )
        def name = positione.name
        if(positione) {
            positione.delete()
            flash.message = "Position '${name}' deleted"
            redirect(action:list)
        }
        else {
            flash.message = "Position not found with id ${params.id}"
            redirect(action:list)
        }
    }

    def edit = {
        def positione = Positione.get( params.id )

        if(!positione) {
            flash.message = "Position not found with id ${params.id}"
            redirect(action:list)
        }
        else {
            return [ positione : positione ]
        }
    }

    def update = {
        def positione = Positione.get( params.id )
        if(positione) {
            positione.properties = params
            if(!positione.hasErrors() && positione.save()) {
                flash.message = "Position ${params.name} updated"
                redirect(action:show,id:positione.id)
            }
            else {
                render(view:'edit',model:[positione:positione])
            }
        }
        else {
            flash.message = "Position not found with name ${params.name}"
            redirect(action:edit,id:params.id)
        }
    }

    def create = {
        def positione = new Positione()
        positione.properties = params
        return ['positione':positione]
    }

    def save = {
        def positione = new Positione(params)
        if(!positione.hasErrors() && positione.save()) {
            flash.message = "Position '${positione.name}' created"
            redirect(action:show,id:positione.id)
        }
        else {
            render(view:'create',model:[positione:positione])
        }
    }
}